package com.tjian.fafa.user.module.courier.activity;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;

import com.tjian.fafa.user.R;
import com.tjian.fafa.user.module.courier.interfaces.BaseInterfaces;

/**
 * BaseActivity
 *
 * @author Administrator
 */
public class BaseActivity extends FragmentActivity implements BaseInterfaces
{

    private Dialog loadbar = null;

    @Override
    protected void onCreate(Bundle arg0)
    {

        super.onCreate(arg0);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
    }

    public void SkipActivityforClass(Context ctx, Class<?> cla)
    {
        Intent intent = new Intent();
        intent.setClass(ctx, cla);
        startActivity(intent);
    }

    @Override
    public void initViews()
    {
    }

    @Override
    public void initData()
    {
    }

    public void initProgressDialog()
    {
        if (loadbar == null)
        {
            loadbar = new Dialog(this, R.style.load_dialog);
            LayoutInflater mInflater = this.getLayoutInflater();
            View v = mInflater.inflate(R.layout.anim_load, null);
            loadbar.setContentView(v);
            loadbar.setCancelable(true);
            loadbar.show();
        }
        else
        {
            loadbar.show();
        }
    }

    public void close()
    {
        if (loadbar != null)
        {
            if (loadbar.isShowing())
            {
                loadbar.dismiss();
            }
        }
    }

    @Override
    public void onDestroy()
    {
        super.onDestroy();
        if (loadbar != null)
        {
            //如果activity关闭，解散loadbar
            loadbar.dismiss();
            loadbar = null;
        }
    }
}
